package com.seguriapp.gwt.client.login;

import java.util.Date;
import java.util.List;

import com.google.gwt.event.shared.GwtEvent;
import com.seguriapp.entities.MenuLink;

public class UserLoggedInEvent extends GwtEvent<UserLoggedInEventHandler> {

  public static final Type<UserLoggedInEventHandler> TYPE = new Type<UserLoggedInEventHandler>();

  private final String username;
  private final Date lastDateLoggedIn;
  private final boolean isAdministrator;
  private final List<MenuLink> menuList;

  public UserLoggedInEvent(final String username, final Date lastDateLoggedIn, final boolean isAdministrator, final List<MenuLink> menuList) {
    this.username = username;
    this.lastDateLoggedIn = lastDateLoggedIn;
    this.isAdministrator = isAdministrator;
    this.menuList = menuList;
  }

  @Override
  public GwtEvent.Type<UserLoggedInEventHandler> getAssociatedType() {
    return TYPE;
  }

  @Override
  protected void dispatch(UserLoggedInEventHandler handler) {
    handler.onUserLoggedIn(this);
  }

  public static Type<UserLoggedInEventHandler> getType() {
    return TYPE;
  }

  public String getUsername() {
    return username;
  }

  public Date getLastDateLoggedIn() {
    return lastDateLoggedIn;
  }

  public boolean isAdministrator() {
    return isAdministrator;
  }

  public List<MenuLink> getMenuList() {
    return menuList;
  }

}
